package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.suspectListPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:suspectListMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/10/5 0:25
 * @Version 1.0
 */
@Mapper
public interface suspectListMapp {
    //插入一行数据
    @DS("baodingRussia")
    @Insert("insert into suspectList (" +
            "partName, partSupplier, modelId, " +
            "occurDate, link, position, " +
            "occurPer, partId, describeUse, " +
            "partNum, judgment, fromJudgment, " +
            "fromProcess, unqualified, rework, " +
            "solve, deleteSign, establishTime, " +
            "updateTime, editName) " +
            "VALUES " +
            "(#{partName}, #{partSupplier}, #{modelId}, " +
            "#{occurDate}, #{link}, #{position}, " +
            "#{occurPer}, #{partId}, #{describeUse}, " +
            "#{partNum}, #{judgment}, #{fromJudgment}, " +
            "#{fromProcess}, #{unqualified}, #{rework}, " +
            "#{solve}, #{deleteSign}, #{establishTime}, " +
            "#{updateTime}, #{editName})")
    Integer insertOne(suspectListPojo suspectListPojo);
    //根据ID，查询一行数据
    @DS("baodingRussia")
    @Select("select * from suspectList where id=#{rowsAffected}")
    suspectListPojo selectOneById(int rowsAffected);
    //查询所有数据
    @DS("baodingRussia")
    @Select("select * from suspectList where deleteSign=1")
    List<suspectListPojo> selectAll();
    //根据id，修改一个字段的值
    @DS("baodingRussia")
    @Update("update suspectList set ${filedName}=#{filedVal} where id=#{id}")
    void editOneFiledById(Integer id, String filedName, String filedVal);
    //根据id，修改一行的数据，用在了对大表修改上
    @DS("baodingRussia")
    @Update("update suspectList set " +
            "partName=#{partName}," +
            "partSupplier=#{partSupplier}, " +
            "modelId=#{modelId}," +
            "occurDate=#{occurDate}," +
            "link=#{link}," +
            "position=#{position}," +
            "occurPer=#{occurPer}," +
            "partId=#{partId}," +
            "partNum=#{partNum}," +
            "describeUse=#{describeUse}," +
            "updateTime=#{updateTime}," +
            "deleteSign=#{deleteSign} " +
            "where id=#{id}")
    void EditFiledById(suspectListPojo suspectListPojo);
}
